<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>LINK Instruction</title>
<link href="../edit68k.css" rel="stylesheet" type="text/css">
</head>

<body>
<h1 class="heading">LINK Instruction<BR><hr noshade></h1>
        <BR>
        <span class="text">The instruction LINK creates a stack frame, a temporarily allocated piece of memory on the stack. The instruction is often used in high-level languages when allocating memory for local variables in procedures. When the procedure is deactivated, the variables disappear which saves memory. LINK has two operands. The first is an address register and the second is a twos complement value, which is the size of the frame (often negative since the stack grows backwards). When the instruction is executed, the address register is pushed onto the stack and the newly updated A7 is copied to the address register. The immediate value is added to the Stack register (A7).<BR>
        <BR>
The local memory is accessed by negative shifting the address register. That way you can use local variables without worrying about other data that is pushed or popped from the stack. This is provided you keep in the range you specified when you called the LINK opcode. The instruction UNLK removes the stack frame and restores the stack pointer.<BR>
        <BR>
ADDRESS METHODS: None<BR>
<BR>
DATA LENGTH: N/A<BR>
        <BR>
FLAGS: Unaffected<BR>
<BR>
SYNTAX: LINK An,#&lt;shifting&gt;<BR>
        <BR>
Note that the use of LINK allows Reentrant programs.<BR>
        </span></h1>
</body>
</html>
